package com.fancy.net.stream
{
	import com.fancy.display.notice.DisplayNoticeType;
	import com.fancy.framework.BundleManager;
	import com.fancy.framework.BundleModuleName;
	import com.fancy.framework.BundleNotice;
	import com.fancy.framework.IBundleLeader;
	import com.fancy.logic.notice.LogicNoticeType;
	import com.fancy.net.NetLeader;
	import com.fancy.net.forward.ForwardList;
	import com.fancy.ui.notice.UINoticeType;
	
	import flash.utils.ByteArray;

	public class DecodeBase
	{
		public function DecodeBase()
		{
		}
		
		protected function getMsgId():String { return "0000"; }
		
		protected function makeVO(bytes:ByteArray):Object
		{
			//此处需要被覆盖
			return null;
		}
		
		public function sendToModules(bytes:ByteArray):void
		{
			var leader:IBundleLeader = BundleManager.instance.getLeaderByModuleName(BundleModuleName.NET_CONNECTION);
			var vo:Object = makeVO(bytes);
			var notice:BundleNotice = new BundleNotice();
			notice.body = vo;
			notice.name = getMsgId();
			if(ForwardList.LogicNeed(getMsgId()))
			{
				notice.type = LogicNoticeType.SRV_MSG;
				notice.module = BundleModuleName.GAME_LOGIC;
				leader.send(notice);
			}
			if(ForwardList.UINeed(getMsgId()))
			{
				notice.type = UINoticeType.SRV_MSG;
				notice.module = BundleModuleName.USER_INTERFACE;
				leader.send(notice);
			}
			if(ForwardList.DisplayNeed(getMsgId()))
			{
				notice.type = DisplayNoticeType.SRV_MSG;
				notice.module = BundleModuleName.DISPLAY;
				leader.send(notice);
			}
			if(ForwardList.LoaderNeed(getMsgId()))
			{
				//notice.type = UINoticeType.SRV_MSG;
				//notice.module = BundleModuleName.RESOURCE_LOADER;
				//leader.send(notice);
			}
			if(ForwardList.MapNeed(getMsgId()))
			{
				//notice.type = UINoticeType.SRV_MSG;
				//notice.module = BundleModuleName.MAP;
				//leader.send(notice);
			}
		}
		
	}
}